﻿#ifndef NSSHARE_BASE_NSBASEOBJECT_H_
#define NSSHARE_BASE_NSBASEOBJECT_H_

#include "../platform.h"
#include "atomic.h"

namespace nsshare
{
namespace base
{

class BaseObject
{
public:
    BaseObject();
    BaseObject(const BaseObject & obj);
    BaseObject(const char * tag);
    void operator=(const BaseObject & obj);
};

class NonCopyableObject : public BaseObject
{
protected:
    NonCopyableObject() {};
private:
    //disallow cpoy and assign
    NonCopyableObject(const NonCopyableObject &);
    NonCopyableObject & operator=(const NonCopyableObject &);
};

class RefCountObject : public NonCopyableObject
{
public:
    virtual int IncRef();
    virtual int DecRef();
    virtual void Dispose();

protected:
    RefCountObject();
    RefCountObject(const char * tag);
    virtual ~RefCountObject();

protected:
    Atomic ref_count_;
};

}
}

#endif NSSHARE_NSBASEOBJECT_H_